package cn.snorlaxzjt.LBSserver.business;

import cn.snorlaxzjt.LBSserver.common.BusinessCode;
import cn.snorlaxzjt.LBSserver.common.Result;
import cn.snorlaxzjt.LBSserver.po.entity.Comment;
import cn.snorlaxzjt.LBSserver.po.page.CommentPage;
import cn.snorlaxzjt.LBSserver.service.CommentService;
import cn.snorlaxzjt.LBSserver.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CommentBusiness {

    @Resource
    private CommentService commentService;

    @Resource
    private UserService userService;

    public Result<Void> save(Comment comment){
        comment.setUserId((long)userService.getCurrentUserId());
        commentService.save(comment);
        return BusinessCode.SUCCESS.toResult();
    }

    public Result<Void> del(Long id){
        commentService.del(id);
        return BusinessCode.SUCCESS.toResult();
    }

    public Result<List<CommentPage>> queryCommentByMomentId(Long id) {
        return BusinessCode.SUCCESS.toResult(commentService.queryCommentByMomentId(id));
    }
}

